﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace colas
{
    class Euler
    {
        public double K { get; set; }
        public double H { get; set; }

        public Euler(double _k, double _h)
        {
            this.K = _k;
            this.H = _h;
        }

        public double calcular_tiempo_pedido(int tam, List<linea_Euler> lst)
        {
            linea_Euler li = new linea_Euler();
            li.Time = 0;
            li.Iteration = 1;
            li.Size = tam == (int)Utils.eleccion_tamanio.CHICO ? 20 : 50;
            li.Derivate = (decimal) (- K - 0.3 * Math.Pow((double)(li.Size), 2));
            lst.Add(li);
            do
            {
                li = lst.Last();
                linea_Euler le_actual = new linea_Euler();
                le_actual.Iteration= li.Iteration+1;
                le_actual.Time =(decimal) ((double)li.Time + H) ;
                le_actual.Size = li.Size + (decimal)H * li.Derivate;
                le_actual.Derivate =(decimal) (-K - 0.3*Math.Pow((double)le_actual.Size,2));
                lst.Add(le_actual);
            } while (li.Size > 0);
    
            return (double) li.Time*600;

        }
    }
}
